<template>
	<div class="jk-delete-btn-box">
		<jk-button
			:size="size"
			:icon="scope.row.status === 1 ? 'el-icon-video-pause' : 'el-icon-video-play'"
			:type="scope.row.status === 1 ? 'warning' : 'success'"
			:disabled="disabled"
			:has-permission="getPermission([`${permissionPrefix}:update`])"
			@click="onClick"
		>{{ scope.row.status === 1 ? '停用' : '启用' }}</jk-button>
	</div>
</template>
<script>

    import permissionMixin from '../../../../../mixins/permission-mixin';

    export default {
        name: 'JkDisableAndEnableButton',
        mixins: [permissionMixin],
        props: {
            permissionPrefix: {
                type: String,
                default: ''
            },
            disabled: {
                type: Boolean,
                default: false
            },
            hasPermission: {
                type: Boolean,
                default: true
            },
            scope: {
                type: Object,
                default() {
                    return {};
                }
            },
            size: {
                type: String,
                default: 'mini'
            },
            usePurview: { // 是否使用权限，false代表这个按钮不需要权限来控制
                type: Boolean,
                default: true
            }
        },
        methods: {
            onClick() {
                this.$confirm(`确定${this.scope.row.status === 1 ? '停用' : '启用'}该条数据吗？`, '提示', { type: 'warning' }).then(() => {
                    this.$emit('on-confirm');
                }).catch(() => {});
            },
            onConfirmButton() {
                this.$emit('on-confirm');
            },
            onCancelButton() {}
        }
    };
</script>
